<!-- 心电图 -->
<template>
	<view>
		<Lt-ECG :ecgArr="ecgArr" :pageNum="0"></Lt-ECG>
	</view>
</template>

<script>
	function group(array, subGroupLength) {
		let index = 0;
		let newArray = [];
		while (index < array.length) {
			newArray.push(array.slice(index, index += subGroupLength));
		}
		return newArray;
	}
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				ecgArr: []
			}
		},
		computed: {
			...mapState(['curAccount'])
		},
		created() {
			this.findEcgFirstPage(this.curAccount.detailId)
		},
		methods: {
			findEcgFirstPage(detailId) {
				this.$postAction(this.$deviceapi.getEcgDetail + '?detailId=' + detailId).then(da => {
					let data = [];
					if (da && da.length > 0) {
						for (let i = 0; i < da.length; i++) {
							let list = da[i].data;
							if (list && list.length > 0) {
								list.forEach((item, index) => {
									let ecg = item * 256;
									//data.push(ecg > 128 ? 128 : ecg < -127 ? -127 : ecg);
									data.push(ecg)
								});
							}
						}
					}
					this.ecgArr = [data.slice(0, 7500)]
					// this.ecgArr == group(data.slice(0, 1250 ), 1250)
				});
			}
		}
	}
</script>

<style>

</style>